﻿using CrystalDecisions.CrystalReports.Engine;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace QLHH
{
    /// <summary>
    /// Interaction logic for PrintWindow.xaml
    /// </summary>
    public partial class PrintWindow : Window
    {
        public PrintWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data Source=(local);Initial Catalog=qlvt; User Id=sa; Password=sa";
            SqlDataAdapter da = new SqlDataAdapter();
            SqlCommand secmd = new SqlCommand("select * from hanghoa inner join hoadon on hoadon.mahang=hanghoa.mahang", conn);
            da.SelectCommand = secmd;
            DataSet ds = new DataSet();
            da.Fill(ds, "hoadon");
            ReportDocument report = new ReportDocument();
            report.Load("..\\..\\CR1.rpt");
            report.SetDataSource(ds);
            cr.ViewerCore.ReportSource = report;
        }
    }
}
